package com.key.controller.admin.analysisReport;

import com.github.pagehelper.PageHelper;
import com.key.common.R;
import com.key.common.vo.ACSVO;
import com.key.service.ACSService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author：朕
 * @Package：com.key.controller.admin.analysisReport
 * @Project：ams_system
 * @name：AssetClassificationSummary
 * @Date：2023/2/18 9:10
 * @Filename：AssetClassificationSummary
 */
@Controller
@Api(value = "分析报表",tags = "资产分类汇总的API")
@RequestMapping("/AssetClassificationSummary")
public class AssetClassificationSummaryController {

    @Autowired
    private ACSService acsService;



    @RequestMapping(value = "/findAssetClassificationSummary",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "显示资产分类汇总",notes = "",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true)
    })
    public R findAssetClassificationSummary(Integer currentPage,Integer pageSize){
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        Map<String,Object> acsvos = acsService.findACS();
        if(acsvos.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(acsvos);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            return r;
        }
    }




    @RequestMapping(value = "/findAssetClassificationSummaryByCompany",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "通过公司显示资产分类报表",notes = "传递公司名称",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "companyName",value = "公司名称",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true)
    })
    public R findAssetClassificationSummaryByCompany(String companyName,Integer currentPage,Integer pageSize){
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        Map<String,Object> acsvos = acsService.findACSByCompany(companyName);
        if(acsvos.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(acsvos);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            return r;
        }
    }



    @RequestMapping(value = "/findAssetClassificationSummaryByDepartment",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "通过部门显示资产分类报表",notes = "部门名称",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "depname",value = "部门名称",paramType = "query",dataType = "String",required = true),
            @ApiImplicitParam(name = "currentPage",value = "当前页",paramType = "query",dataType = "int",required = true),
            @ApiImplicitParam(name = "pageSize",value = "页面大小",paramType = "query",dataType = "int",required = true)
    })
    public R findAssetClassificationSummaryByDepartment(String depname, Integer currentPage, Integer pageSize){
        System.out.println("departmentName"+depname);
        System.out.println("p"+pageSize);
        R r = new R();
        PageHelper.startPage(currentPage,pageSize);
        Map<String,Object> acsvos = acsService.findACSByDepartment(depname);
        System.out.println(acsvos);
        if(acsvos.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(acsvos);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            return r;
        }
    }


    @RequestMapping(value = "/findAssetClassificationSummaryById",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "通过分类编码显示资产分类报表",notes = "分类Id",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Id",value = "分类Id",paramType = "query",dataType = "int",required = true),
    })
    public R findAssetClassificationSummaryById(Integer Id){
        R r = new R();
        List<ACSVO> acsvos = acsService.findACSById(Id);
        if(acsvos.size()>0){
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(acsvos);
            return r;
        }else{
            r.setCode(500);
            r.setMsg("查询失败");
            return r;
        }
    }

}